#include<bits/stdc++.h>

using namespace std;

//1239123=123_123=>123123
void fun(char *s) {
    int n = strlen(s);
    if (n <= 1)strcpy(s, "0");
    char t[1000];
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] > s[i + 1]) {
            strcpy(t, s + i + 1);
            s[i] = 0;
            strcat(s, t);
            return;
        }
    }
    s[n - 1] = 0;
}

void show(char *a) {
    char *p = a;
    while (*p == '0' && *(p + 1))++p;
    while (*p)cout << *p++;
}

int main() {
    //freopen("e.in","r",stdin);
    char s[1000] = "1024";
    cin >> s;
    int k;
    cin >> k;
    while (k--)
        fun(s);
    show(s);
}

